package com.moji.controller.web;


import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.gson.Gson;
import com.moji.common.base.ApiResult;
import com.moji.common.entity.MyPage;
import com.moji.common.utils.HttpUtils;
import com.moji.entity.MjHomeProduct;
import com.moji.entity.MjHomeSolution;
import com.moji.entity.MjProduct;
import com.moji.entity.MjProductPurchase;
import com.moji.entity.dto.RouterrDto;
import com.moji.entity.vo.MijiMoYao3;
import com.moji.entity.vo.MijiMoYaoVo1;
import com.moji.entity.vo.MojiMoYaoVo3;
import com.moji.service.MjProductPurchaseService;
import com.moji.service.MjProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 产品表(MjProduct)表控制层
 *
 * @author makejava
 * @since 2024-07-21 14:36:36
 */
@RestController
@RequestMapping("web/mjProduct")
@Api(tags = "产品列表相关web接口", value = "产品列表相关web接口")
public class MjProductController {
    /**
     * 服务对象
     */
    @Resource
    private MjProductService mjProductService;
    @Resource
    private MjProductPurchaseService mjProductPurchaseService;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @GetMapping
    @ApiOperation(value = "获取全部产品列表,不需要传参数")
    public ApiResult<List<MjProduct>>queryByPage() {

        return ApiResult.ok(this.mjProductService.queryByPage());
    }

    /**
     * 通过主键查询单条数据
     *
     * @return 单条数据
     */
    @PostMapping("/detail")
    @ApiOperation(value = "根据id查看产品",response = MjProduct.class)
    public ApiResult<MjProduct> queryById(@RequestBody RouterrDto routerrDto) {
        if (this.mjProductService.queryById(routerrDto) == null) {
            return ApiResult.routerFailed("查无此router");
        }
        return ApiResult.ok(this.mjProductService.queryById(routerrDto));
    }

}

